QuickOPC User's Guide and Reference
OPC Classic Item Changed Event or Callback
Development Models > Imperative Programming Model > Imperative Programming Model for OPC Data (Classic and UA) > Subscribing to Information (OPC Data) > OPC Classic Item Changed Event or Callback

When there is a change in a value of an OPC item you have subscribed to, the EasyDAClient object generates an  ItemChanged event. For subscription mechanism to be useful, you should hook one or more event handlers to this event.

To be more precise, the ItemChanged event is actually generated in other cases, too.

First of all, you always receive at least one ItemChanged event notification after you make a subscription; this notification either contains the initial data for the item, or an indication that data is not currently available. This behavior allows your application to rely on the component to provide at least some information for each subscribed item.

Secondly, the ItemChanged event is generated every time the component loses connection to the item, and when it reestablishes the connection. This way, your application is informed about any problems related to the item, and can process them accordingly if needed.

You will also receive the ItemChanged notification if the quality of the item changes (not just its actual data value).

The ItemChanged event notification contains an EasyDAItemChangedEventArgs argument. You will find all kind of relevant data in this object. Some properties in this object contain valid information no matter what kind of change the notification is about. These properties are inside the Arguments property.

For further processing, your code should always inspect the value of  Exception property of the event arguments. If this property is set to a null reference, the notification carries an actual change in item’s data, and the Vtq property has the new value, timestamp and quality of the item, in form of DAVtq object. If the Exception property is not a null reference, there has been an error related to the item, and the Vtq property is not valid. In such case, the Exception property contains information about the problem.

The ItemChanged event handler is called on a thread determined by the EasyDAClient component. For details, please refer to “Multithreading and Synchronization” chapter under “Advanced Topics”.

In short, however, we can say that if you are writing e.g. Windows Forms application, the component takes care of calling the event handler on the user interface thread of the form, making it safe for your code to update controls on the form, or do other form-related actions, from the event handler.

See Also

Examples - OPC Data Access